package pers.fjl.test.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import pers.fjl.common.entity.QueryPageBean;
import pers.fjl.common.po.Department;
import pers.fjl.common.po.Staff;
import pers.fjl.test.dao.DeptDao;
import pers.fjl.test.dao.StaffDao;
import pers.fjl.test.service.DeptService;
import pers.fjl.test.service.StaffService;

import javax.annotation.Resource;


@Service
public class DeptServiceImpl extends ServiceImpl<DeptDao, Department> implements DeptService {
    @Resource
    private DeptDao deptDao;

    @Cacheable(value = {"DeptMap"})
    public Page<Department> findPage(QueryPageBean queryPageBean) {
        //设置分页条件
        Page<Department> page = new Page<>(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
        //设置查询条件
        QueryWrapper<Department> wrapper = new QueryWrapper<>();
        wrapper.like(queryPageBean.getQueryString() != null, "dname", queryPageBean.getQueryString());
        return deptDao.selectPage(page, wrapper);
    }
}
